package NetWork;

import java.util.Queue;
import java.util.Vector;
import Global.TransObject;
class DelegateThreadObj extends Thread
{
	NetWorkDelegate	delegate;
	String			hostString;
	Object			obj;
	int				portNum;

	public DelegateThreadObj(NetWorkDelegate d, String host, int port, Object o)
	{
		delegate = d;
		hostString = host;
		portNum = port;
		obj = o;
	}

	public void run()
	{
		//delegate.didReceiveObject(hostString, portNum, obj);
	}
}
public class ObjectScheduler extends StringScheduler
{
	public ObjectScheduler(String host, int port,Queue<TransObject> queue)
	{
		super(host, port,queue);
	}

	public void run()
	{
		while (keepAlive)
		{
			TransObject transObject = transObjectQueue.poll();
			if(transObject != null)
			{
				Vector<NetWorkDelegate> vector = TransmissionUtil.delegateVector;
				for (NetWorkDelegate d : vector)
				{
					d.didReceiveObject(transObject.siteType,hostsString, portNum, transObject.obj);
				}
			}
			else
			{
				try
				{
					sleep(100);
				}
				catch (InterruptedException e)
				{
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
}
